/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   Module Name          : com.yaodian100.crm.workorder.entity.Question
   Module Description   :

   Date Created      : 2009/11/24
   Original Author   : andy.chuang
   Team              : yaodian100
   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   MODIFICATION HISTORY
   ------------------------------------------------------------------------------
   Date Modified       Modified by       Comments
   ------------------------------------------------------------------------------
   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
package com.yaodian100.crm.cs.entity;

import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.hibernate.annotations.CollectionOfElements;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.annotations.Parameter;

import com.yaodian100.core.common.entity.CommonEntity;

//import com.yaodian100.crm.workorder.entity.WorkOrderType;

/**
 * @author andy.chuang
 * 
 */
@Entity
@Table(name = "CRM_CS_QUESTION")
public class Question extends CommonEntity {

	/**
     * 
     */
	private static final long serialVersionUID = -5754416849628401468L;
	private String id;
	private String shortDesc;
	private String description;
	// CSR备注
	private String comment;
	// private WorkOrderType type;
	private FromChannel channel;
	private String email;
	private Boolean isMember = true;
	private String memberId;
	private Answer answer;
	private Integer status = 0;
	private Map<String, QuestionExtraValue> extraValue;
	private QuestionType type;
	private Date answeredDate;
	private List<Answer> answers;
	private String category;
	private String deliver;
	private String orgQuestionId;

	/**
	 * @return the orgQuestionId
	 */
	@Column(length = 32)
	public String getOrgQuestionId() {
		return orgQuestionId;
	}

	/**
	 * @param orgQuestionId the orgQuestionId to set
	 */
	public void setOrgQuestionId(String orgQuestionId) {
		this.orgQuestionId = orgQuestionId;
	}

	/**
	 * @return the answers
	 */
	@OneToMany(mappedBy = "question")
	@LazyCollection(LazyCollectionOption.FALSE)
	@OrderBy("createDate desc")
	public List<Answer> getAnswers() {
		return answers;
	}

	/**
	 * @param answers the answers to set
	 */
	public void setAnswers(List<Answer> answers) {
		this.answers = answers;
	}

	/**
	 * @return the answeredDate
	 */
	public Date getAnsweredDate() {
		return answeredDate;
	}

	/**
	 * @param answeredDate the answeredDate to set
	 */
	public void setAnsweredDate(Date answeredDate) {
		this.answeredDate = answeredDate;
	}

	/**
	 * @return the email
	 */
	@Column(length = 150)
	public String getEmail() {
		return email;
	}

	/**
	 * @param email the email to set
	 */
	public void setEmail(String email) {
		this.email = email;
	}

	/**
	 * @return the isMember
	 */
	public Boolean getIsMember() {
		return isMember;
	}

	/**
	 * @param isMember the isMember to set
	 */
	public void setIsMember(Boolean isMember) {
		this.isMember = isMember;
	}

	/**
	 * @return the extraValue
	 */
	// @MapKey(name = "name")
	@org.hibernate.annotations.MapKey(columns = { @Column(name = "name") })
	@OneToMany(mappedBy = "question")
	@CollectionOfElements(targetElement = QuestionExtraValue.class)
	@LazyCollection(LazyCollectionOption.FALSE)
	public Map<String, QuestionExtraValue> getExtraValue() {
		return extraValue;
	}

	/**
	 * @param extraValue the extraValue to set
	 */
	public void setExtraValue(Map<String, QuestionExtraValue> extraValue) {
		this.extraValue = extraValue;
	}

	/**
	 * @return the type
	 */
	@ManyToOne(cascade = {})
	public QuestionType getType() {
		return type;
	}

	/**
	 * @param type the type to set
	 */
	public void setType(QuestionType type) {
		this.type = type;
	}

	/**
	 * @return the comment
	 */
	@Column(name = "question_comment", length = 4000)
	public String getComment() {
		return comment;
	}

	/**
	 * @param comment the comment to set
	 */
	public void setComment(String comment) {
		this.comment = comment;
	}

	/**
	 * @return the status
	 */
	public Integer getStatus() {
		return status;
	}

	/**
	 * @param status the status to set
	 */
	public void setStatus(Integer status) {
		this.status = status;
	}

	/**
	 * @return the answer
	 */
	@ManyToOne
	public Answer getAnswer() {
		return answer;
	}

	/**
	 * @param answer the answer to set
	 */
	public void setAnswer(Answer answer) {
		this.answer = answer;
	}

	/**
	 * @return the memberId
	 */
	@Column(length = 10)
	public String getMemberId() {
		return memberId;
	}

	/**
	 * @param memberId the memberId to set
	 */
	public void setMemberId(String memberId) {
		this.memberId = memberId;
	}

	/**
	 * @return the id
	 */
	/*
	 * @Id
	 * 
	 * @GeneratedValue(generator = "system-uuid")
	 * 
	 * @GenericGenerator(name = "system-uuid", strategy = "uuid")
	 * 
	 * @Column(length = 32)
	 */
	@Id
	@GeneratedValue(generator = "seq_crm_cs_question")
	@SequenceGenerator(name = "seq_crm_cs_question", sequenceName = "SEQ_CRM_CS_QUESTION")
	@GenericGenerator(name = "seq_crm_cs_question", strategy = "com.yaodian100.core.common.dao.hibernate.QuestionSeqGenerator", parameters = { @Parameter(name = "sequence", value = "SEQ_CRM_CS_QUESTION") })
	public String getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(String id) {
		this.id = id;
	}

	/**
	 * @return the shortDesc
	 */
	@Column(length = 255)
	public String getShortDesc() {
		return shortDesc;
	}

	/**
	 * @param shortDesc the shortDesc to set
	 */
	public void setShortDesc(String shortDesc) {
		this.shortDesc = shortDesc;
	}

	/**
	 * @return the description
	 */
	@Column(length = 4000)
	public String getDescription() {
		return description;
	}

	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	// /**
	// * @return the type
	// */
	// @ManyToOne
	// public WorkOrderType getType() {
	// return type;
	// }
	//
	// /**
	// * @param type the type to set
	// */
	// public void setType(WorkOrderType type) {
	// this.type = type;
	// }

	/**
	 * @return the channel
	 */
	@ManyToOne
	public FromChannel getChannel() {
		return channel;
	}

	/**
	 * @param channel the channel to set
	 */
	public void setChannel(FromChannel channel) {
		this.channel = channel;
	}

	/**
	 * @return the category
	 */
	@Column(length = 255)
	public String getCategory() {
		return category;
	}

	/**
	 * @param category the category to set
	 */
	public void setCategory(String category) {
		this.category = category;
	}

	/**
	 * @return the deliver
	 */
	@Column(length = 32)
	public String getDeliver() {
		return deliver;
	}

	/**
	 * @param deliver the deliver to set
	 */
	public void setDeliver(String deliver) {
		this.deliver = deliver;
	}

}
